<?php

use yii\helpers\Url;

$this->title = '渠道汇总统计';
$this->registerJsFile('@web/assets/apache-echarts-5.2.2/dist/echarts.js', ['position' => \yii\web\View::POS_HEAD]);
?>

<style type="text/css">
    #tables {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
    }

    #tables div.pane {
        background-color: #abcdef;
        border-radius: 5px;
        padding: 13px 3px;
        flex: 1;
        margin: 1em;
        min-width: 400px;
    }

    #tables div.pane .title {
        height: 30px;
        line-height: 20px;
        padding-left: 20px;
        font-weight: 800;
    }

    #tables div.pane .content {
        background-color: #fff;
    }

    #tables div.pane .content table {
        width: 100%;
    }

    #tables div.pane .content td {
        border-bottom: #ddd 1px solid;
        border-left: #ddd 1px solid;
        text-align: center;
        padding: 0.4em;
    }
</style>

<div id="balance" style="width:300px;margin:1em auto;">
    <div id="search" style="width:420px;background:#ffff87;border:#ccc 1px solid;padding:0.5em 1em;">
        <b style="color: red;">从：</b>
        <input style="width:130px;" id="input_month_start" type="date" value="<?= $month_start ?>" onchange="window.search(this.value)" />
        <b style="color: red;">至：</b>
        <input style="width:130px;" id="input_month_end" type="date" value="<?= $month_end ?>" onchange="window.search(this.value)" />
        <button onclick="window.select_month('previous')" type="button" class="btn btn-default btn-sm">查询</button>
    </div>

    <div id="tables">
        <div class="pane">
            <div class="title">渠道汇总</div>
            <div class="content">
                <table>
                    <tr style="background-color: #d8e4bc;">
                        <td width="60">渠道</td>
                        <td width="60">到诊人数</td>
                    </tr>
                    <?php if (null != $data && count($data) > 0) {
                        foreach ($data as $name => $numc) {
                    ?>
                            <tr>
                                <td><?= $name ?></td>
                                <td><?= $numc ?></td>
                            </tr>
                    <?php
                        }
                    } ?>
                </table>
            </div>
        </div>
    </div>

</div>

<script type="text/javascript">
    window.select_month = function() {
        var month_start = $('#input_month_start').val();
        var month_end = $('#input_month_end').val();
        window.location.href = "<?= Url::toRoute('statistics/way') ?>&month_start=" + month_start + "&month_end" + month_end;
    };
</script>